package traveldream.ejb.DTO;

import java.util.Date;
import java.sql.Time;

import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;


public class TransportationDTO {
	
	private int id;
	@Length(max=31,message = "You have exceded max number of car")
	@NotEmpty(message = "You must specify a Name")
	private String name;
	@Min(value=1)
	private int availablePlaces;
	@Length(max=31,message = "You have exceded max number of car")
	@Pattern(regexp = "(^[a-zA-Z]+$)",
            message = "You must specify a type")
	private String type;
	private Time arrivalTime;
	private Time departureTime;
	private Date arrivalDate;
	private Date departureDate;
	@Length(max=31,message = "You have exceded max number of car")
	@Pattern(regexp = "(^[a-zA-Z]+$)",
            message = "You must specify a arrivalPlace")
	private String arrivalPlace;
	@Length(max=31,message = "You have exceded max number of car")
	@Pattern(regexp = "(^[a-zA-Z]+$)",
            message = "You must specify a departurePlace")
	private String departurePlace;
	@Length(max=31,message = "You have exceded max number of car")
	@Pattern(regexp = "(^[a-zA-Z]+$)",
            message = "You must specify a company")
	private String company;
	@Min(value = 1)
	private int price;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAvailablePlaces() {
		return availablePlaces;
	}
	public void setAvailablePlaces(int availablePlaces) {
		this.availablePlaces = availablePlaces;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Time getArrivalTime() {
		return arrivalTime;
	}
	public void setArrivalTime(Time arrivalTime) {
		this.arrivalTime = arrivalTime;
	}
	public Time getDepartureTime() {
		return departureTime;
	}
	public void setDepartureTime(Time departureTime) {
		this.departureTime = departureTime;
	}
	public Date getArrivalDate() {
		return arrivalDate;
	}
	public void setArrivalDate(Date arrivalDate) {
		this.arrivalDate = arrivalDate;
		setArrivalTime(new Time(arrivalDate.getHours(), arrivalDate.getMinutes(), 0));
	}
	public Date getDepartureDate() {
		return departureDate;
	}
	public void setDepartureDate(Date departureDate) {
		this.departureDate = departureDate;
		setDepartureTime(new Time(departureDate.getHours(), departureDate.getMinutes(), 0));
	}
	public String getArrivalPlace() {
		return arrivalPlace;
	}
	public void setArrivalPlace(String arrivalPlace) {
		this.arrivalPlace = arrivalPlace;
	}
	public String getDeparturePlace() {
		return departurePlace;
	}
	public void setDeparturePlace(String departurePlace) {
		this.departurePlace = departurePlace;
	}
	public String getCompany() {
		return company;
	}
	public void setCompany(String company) {
		this.company = company;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}
	
	public boolean equals(TransportationDTO t){
		return t.arrivalDate.equals(arrivalDate) && t.arrivalPlace.equals(arrivalPlace) && t.arrivalTime.equals(arrivalTime) && t.availablePlaces == availablePlaces 
				&& t.company.equals(company) && t.departureDate.equals(departureDate) && t.departurePlace.equals(departurePlace) && t.departureTime.equals(departureTime)
				&& t.name.equals(name) && t.price == price && t.type.equals(type);
 	}
}
